"""4.5 【练习题】多个资源文件大模型如何决策？"""
from mcp.server.fastmcp import FastMCP

#创建MCP实例
mcp = FastMCP("Resource MCP Server")

#创建资源
@mcp.resource(
    uri="file:///fetch_book.txt",
    name="book",
    description="查询书籍信息",
    mime_type="text/plain",
)
#查询书籍信息
def query_book():
    """
     读取本地文件books.txt,获取图书信息
     """
    with open("books.txt", "r",encoding="utf-8") as f:
        content = f.read()
        return content


#创建资源
@mcp.resource(
    uri="file:///fetch_staff_manu.txt",
    name="staff_manu",
    description="咨询公司的员工手册",
    mime_type="text/plain",
)
#查询员工手册信息
def fetch_staff_manu():
    """
     读取本地文件staff_menu.txt,获取员工手册信息，包括员工的联系方式，工作地点、福利等信息
     """
    with open("staff_manu.txt", "r",encoding="utf-8") as f:
        content = f.read()
        return content
if __name__ == "__main__":
    print("Resource MCP Server is running...")
    mcp.run(transport="sse")